﻿using System;
using System.Diagnostics;

namespace AsyncLoggers.TraceListeners.Demo
{
    class Program
    {
        static void Main(string[] args)
        {
            // sample #1 - using listeners created in configuration
            Stopwatch stopwatch = Stopwatch.StartNew();

            for (int i = 0; i < 100; i++)
            {
                Trace.TraceInformation("Info");
            }

            Console.WriteLine("Synchronous version:");
            Console.WriteLine(stopwatch.Elapsed);

            Trace.Flush();

            TraceAsyncLoggers.SwapAllTraceListenersForAsynchronous();

            stopwatch = Stopwatch.StartNew();

            for (int i = 0; i < 100; i++)
            {
                Trace.TraceInformation("Info");
            }

            Console.WriteLine("Asynchronous version:");
            Console.WriteLine(stopwatch.Elapsed);

            Trace.Flush();

            Console.ReadLine();
        }
    }
}